package com.atguigu.study.test;

import java.io.Serializable;
import java.util.ArrayList;

public class OOMDemo implements Serializable {
    public static void main(String[] args) throws InterruptedException {
        ArrayList<Dog> list = new ArrayList<>();
        while (true){
            System.out.println("最大堆大小: Xmx=");
            System.out.println(Runtime.getRuntime().maxMemory()/1024.0/1024+"M");

            System.out.println("剩余堆大小: free mem=");
            System.out.println(Runtime.getRuntime().freeMemory()/1024.0/1024+"M");

            System.out.println("当前堆大小: total mem=");
            System.out.println(Runtime.getRuntime().totalMemory()/1024.0/1024+"M");

            list.add(new Dog());

            Thread.sleep(100);
            System.out.println();
        }
    }

}
class Dog{
    Integer id;
    String dogName;
    byte[] bytes=new byte[1*1024*1024];
}

class Student{
    public static  final int SNUMBER =48;
    int sid;
    String sname;
    static  String className = "java1229";
}